ThisModuleName := py_llm
RemoteImagePath := /home/ubuntu/images
RemoteScriptPath := /home/ubuntu/scripts
RemoteHost := ubuntu@192.168.3.42

image:
	cp ../proto/llm_pb2.py ./
	cp ../proto/llm_pb2_grpc.py ./
	docker build . -t py_llm
	docker save py_llm:latest -o py_llm.tar
upload:
	scp  py_llm.tar $(RemoteHost):/home/ubuntu/images/
	ssh  $(RemoteHost) 'cd  $(RemoteScriptPath); docker-compose stop $(ThisModuleName)'
	ssh  $(RemoteHost) 'cd  $(RemoteScriptPath); docker-compose rm -v -f $(ThisModuleName)'
	-ssh  $(RemoteHost) 'docker rmi $(ThisModuleName):latest'
	ssh  $(RemoteHost) 'docker load -i $(RemoteImagePath)/$(ThisModuleName).tar'
	ssh  $(RemoteHost) 'cd  $(RemoteScriptPath); docker-compose up -d $(ThisModuleName)'
	ssh  $(RemoteHost) 'cd  $(RemoteScriptPath); docker-compose up -d $(ThisModuleName)'
all: image upload

.PHONY: image